package com.fcy.teamwork.business.self

import android.app.Dialog
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.fragment.app.activityViewModels
import com.fcy.teamwork.R
import com.fcy.teamwork.databinding.BottomSheetFragmentAddNewSkillBinding
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

class AddSkillBottomSheetFrag : BottomSheetDialogFragment() {
    private lateinit var binding: BottomSheetFragmentAddNewSkillBinding
    private val vm: SelfInfoVM by activityViewModels()
    var listener: (String) -> Unit = {}
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        binding = BottomSheetFragmentAddNewSkillBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        return BottomSheetDialog(requireContext(), R.style.BottomSheetStyle)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding.actionBar.apply {
            ibFinish.visibility = View.VISIBLE
            tvTitle.text = "添加新技能"
            ibFinish.setOnClickListener {
                listener(binding.etNewSkill.text.toString())
                vm.addSkill(binding.etNewSkill.text.toString())
                dismiss()
            }
            ibBack.setOnClickListener {
                dismiss()
            }
        }

    }


}